<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>Open Flash Chart 2 demo</title>  
<script type="text/javascript" src="../jQuery.js"></script>  
<script type="text/javascript" src="../jquery.json-2.2.min.js"></script>  
<script type="text/javascript" src="../swfobject.js"></script>  
</head>  
<body>  
<p>Hello World ofc2</p>  
<div id="my_ofc2_chart"></div>  
<br>  
<input type="button" name="btn" value="stop" onclick="changeRefresh(this)">  
</body>  
<script type="text/javascript">  
var portType = "random";  
var portId = "1000";  
var portIndex = "5";  
var ofc2_chart_id="my_ofc2_chart";  
var ofc2_url = 'd2.js';  
var flash_param="ofc2_param="+ofc2_chart_id+","+portType+","+portId+","+portIndex;  
swfobject.embedSWF("../../img/open-flash-chart.swf", ofc2_chart_id,  
  "600", "300", "9.0.0", "expressInstall.swf",  
   {"data-file":ofc2_url+"?"+flash_param},  
  {"wmode":"transparent"}  
  );  
 //refresh_ofc2_chart();  
var o_time = setInterval('refresh_ofc2_chart()', 5*1000);  
  
 function changeRefresh(obj){  
    if(obj.value=="stop"){  
        if(null!=o_time){clearInterval(o_time );}  
        obj.value="start"  
    }else{  
        clearInterval(o_time );  
        o_time = setInterval('refresh_ofc2_chart()', 5*1000);  
        obj.value="stop"  
    }  
      
 }  
  
function refresh_ofc2_chart(){  
    //var pars = Object.toQueryString(par);  
	if(ofc2_url == 'd1.js'){
		ofc2_url='d2.js';
	}else{
		ofc2_url='d1.js';
	}
    /*var myAjax = new Ajax.Request(ofc2_url,   
        {  
            encoding :'UTF-8',  
            method :'get',  
            parameters :flash_param,  
            asynchronous :false,  
            onComplete : showResponse  
        }  
    );  */
	loadData(ofc2_url,showResponse);
}  

function loadData (url, onSucc){
		jQuery.ajax({
			type : 'GET',
			dataType : 'html',
			url : url,
			success : function(data) {
				if(onSucc){
					onSucc(data);
				}
			},
			error : function(data) {
					alert(data)
			}
		});
}

function showResponse(rep) {  
    //var chartdata = rep.evalJSON(true);  
    //alert(JSON.stringify(chartdata));  
    var tmp = findSWF(ofc2_chart_id);  
    x = tmp.load(rep);  
}  
  
  
function findSWF(movieName) {  
  if (navigator.appName.indexOf("Microsoft")!= -1) {  
    return window[movieName];  
  } else {  
    return document[movieName];  
  }  
}  
</script></html>  